
package com.faithbj.device.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.faithbj.device.dao.CostDao;
import com.faithbj.device.model.configuration.Pager;
import com.faithbj.device.model.entity.Cost;
import com.faithbj.device.service.CostService;

/**
 * @author jrn E-mail: rinanjin@gmail.com
 * @version 0.1 
 * 创建时间：2012-5-16 下午08:19:57
 * 类说明
 */
@Service("costService")
public class CostServiceImpl implements CostService
{
	@Resource(name="costDao")
	private CostDao costDao;
	
	public CostDao getCostDao()
	{
		return costDao;
	}

	@Resource(name="costDao")
	public void setCostDao(CostDao costDao)
	{
		this.costDao = costDao;
	}

	@Override
	public void delete(String id)
	{
		costDao.delete(id);
		costDao.flush();
	}
	
	@Override
	public void batchDelete(String[] ids)
	{
		costDao.delete(ids);
		costDao.flush();
	}

	@Override
	public Pager findByPager(Pager pager, Cost cost)
	{
		return costDao.findByPager(pager, cost);
	}

	@Override
	public Cost get(String id)
	{
		Cost cost = costDao.get(id);
		costDao.clear();
		return cost; 
	}

	@Override
	public String save(Cost cost)
	{
		String id = costDao.save(cost);
		costDao.flush();
		costDao.evict(cost);
		cost = costDao.load(id);
		return id;
	}

	@Override
	public String update(Cost cost)
	{
		String id = cost.getId();
		costDao.update(cost);
		costDao.flush();
		costDao.evict(cost);
		cost = costDao.load(id);
		return id;
	}
}
